#include "symbol.h"

/**
 * @brief akfs_trace_declare 
 *   进程exec点
 */
akfs_trace_declare(security_bprm_check);
static int akfs_trace_function(security_bprm_check)(struct linux_binprm *bprm)
{
    int (*run)(struct linux_binprm *) = (void *)akfs_trace_get_original(security_bprm_check);
    assert_goto(bprm && bprm->file ,out ,);

    process_bprm_put(current ,bprm);

out:
    return run(bprm);
}

/**
 * @brief akfs_trace_declare 
 *   进程fork点
 */
akfs_trace_declare(do_fork);
static long akfs_trace_function(do_fork)(unsigned long clone_flags,
        unsigned long stack_start,
        unsigned long stack_size,
        int __user *parent_tidptr,
        int __user *child_tidptr)
{
    long (*run)(unsigned long ,unsigned long,
            unsigned long ,int __user *,
            int __user *) = (void *)akfs_trace_get_original(do_fork);
    long rv;

    rv = run(clone_flags ,stack_start ,stack_size ,parent_tidptr ,child_tidptr);

    process_fork_put(current ,rv);

    return rv;
}

/**
 * @brief akfs_trace_declare 
 *   进程exit点
 */
akfs_trace_declare(do_group_exit);
static void akfs_trace_function(do_group_exit)(int exit_code)
{
    void (*run)(int) = (void *)akfs_trace_get_original(do_group_exit);

    process_exit_put(current);

    run(exit_code);
}
